import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Test test = new Test();
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            TreeNode root = Test.createTree(str);
            test.levelOrder(root);
        }
    }
}